package com.example.a10928.weifriend;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDexApplication;
import android.util.Log;


import com.example.a10928.weifriend.http.AppModule;
import com.example.a10928.weifriend.http.poll.PollingManager;
import com.example.a10928.weifriend.util.Utils;
import com.previewlibrary.ZoomMediaLoader;
import com.tencent.smtt.sdk.QbSdk;


public class App extends MultiDexApplication {
    public static PollingManager manager;
    public static AppComponent mAppComponent;
    public static android.os.Handler handler;
    public static App instance;

    public static Activity activity=null;

    @Override
    public void onCreate() {
        super.onCreate();



        handler=new android.os.Handler();

        instance = this;

        Utils.init(this);

        initX5();
        ZoomMediaLoader.getInstance().init(new TestImageLoader());
    }




    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        mAppComponent = DaggerAppComponent.builder().appModule(new AppModule(base)).build();
    }

    public static AppComponent app() {
        return mAppComponent;
    }

    public static Application getAppInstance(){
        return instance;
    }


    public void initX5(){
        //搜集本地tbs内核信息并上报服务器，服务器返回结果决定使用哪个内核。

        QbSdk.PreInitCallback cb = new QbSdk.PreInitCallback() {

            @Override
            public void onViewInitFinished(boolean arg0) {
                // TODO Auto-generated method stub
                //x5內核初始化完成的回调，为true表示x5内核加载成功，否则表示x5内核加载失败，会自动切换到系统内核。
                Log.d("app", " onViewInitFinished is " + arg0);
            }

            @Override
            public void onCoreInitFinished() {
                // TODO Auto-generated method stub
            }
        };
        //x5内核初始化接口
        QbSdk.initX5Environment(getApplicationContext(),  cb);
    }




}
